/* eslint-disable no-multiple-empty-lines */
/* eslint-disable prettier/prettier */
import { Flex, Tag, Tooltip, Typography } from "antd"
import { ColumnGroupType, ColumnType } from "antd/es/table"

import { SaveButton } from "@/components/common/saveButton"
import { mappingBusinessModel } from "@/utils"
import { handleNumber, handleNumberColor } from "@/utils/util"

import { renderNullableValue } from "./venueProfitAndLoss"
const getAuditStatusClass = (rowData: any) => {
	let className = "normalRgba"
	if (rowData.lockStatus === 11) {
		className = "deleteRgba"
	} else if (rowData.lockStatus === 13) {
		className = "failRgba"
	} else if (rowData.lockStatus === 12) {
		className = "rejectRgba"
	} else if (rowData.lockStatus === 7) {
		// 待出款
	} else if (Number(rowData.lockStatus) === 1) {
		className = "lockingRgba"
	}
	return className
}
export const IncomeCheckRecordSetupColumns = (
	getLabel: (value: string | number, modal: string, strictlyLabel?: boolean, customDictArr?: any[]) => any,
	newFormat: (p: { id: string } | string) => string,
	_getFromDic: (arg: string, strictlyLabel?: boolean) => any,
	formatMessage: any
): Record<string, ColumnGroupType<any> | ColumnType<any>> => ({
	incomeCheckRecord_reportDate: {
		key: "reportDate",
		dataIndex: "reportDate",
		title: newFormat("report.rebate_cycle"),
		align: "center"
	},
	incomeCheckRecord_proxyName: {
		key: "proxyName",
		dataIndex: "proxyName",
		title: newFormat("funds.proxy_name"),
		align: "center",
		render: (_, record: any) => (
			<Flex align="center" gap={5} justify="center">
				<Typography>{record.proxyName}</Typography>
				<SaveButton value={record.proxyName} />
			</Flex>
		)
	},
	incomeCheckRecord_businessModel: {
		key: "businessModel",
		dataIndex: "businessModel",
		title: newFormat("label.member.business_model"),
		align: "center"
	},
	incomeCheckRecord_merchantName: {
		key: "merchantName",
		dataIndex: "merchantName",
		title: newFormat("agent.belong_merchant"),
		align: "center"
	},
	incomeCheckRecord_adjustAmount: {
		key: "adjustAmount",
		dataIndex: "adjustAmount",
		title: newFormat("funds.income_amount"),
		align: "center",
		render: (text: string, record: any) => {
			return (
				<span style={{ color: handleNumberColor(record.adjustAmount) }}>{handleNumber("USDT", record.adjustAmount, 2)} </span>
			)
		}
	},
	incomeCheckRecord_operatorName: {
		key: "operatorName",
		dataIndex: "operatorName",
		title: newFormat("common.updateBy"),
		align: "center"
	},
	incomeCheckRecord_operatorDate: {
		key: "operatorDate",
		dataIndex: "operatorDate",
		title: newFormat("common.updateAt"),
		align: "center"
	},
	incomeCheckRecord_remark: {
		key: "remark",
		dataIndex: "remark",
		title: newFormat("common.remark"),
		align: "center"
	},
	incomeCheckRecord_dxServiceFeeRebateAmount: {
		key: "dxServiceFeeRebateAmount",
		dataIndex: "dxServiceFeeRebateAmount",
		title: newFormat("dxn.card_ables_list.dx_service_fee_rebate_amount"),
		align: "center",
		width: 120
	},
	incomeCheckRecord_dxInsurancePartsAmount: {
		key: "dxInsurancePartsAmount",
		dataIndex: "dxInsurancePartsAmount",
		title: newFormat("dxn.card_ables_list.dx_insurance_parts_amount"),
		align: "center",
		width: 120
	},
	incomeCheckRecord_otherVenueRebateAmount: {
		key: "otherVenueRebateAmount",
		dataIndex: "otherVenueRebateAmount",
		title: newFormat("dxn.card_ables_list.value_added_total_amount"),
		align: "center",
		width: 120
	},
	incomeCheckRecord_currentIncomeAmount: {
		key: "currentIncomeAmount",
		dataIndex: "currentIncomeAmount",
		title: newFormat("funds.fund_audit.current_period_revenue"),
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	incomeCheckRecord_adjustIncomeAmount: {
		key: "adjustIncomeAmount",
		dataIndex: "adjustIncomeAmount",
		title: newFormat("funds.fund_audit.revenue_adjustment"),
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	incomeCheckRecord_realIncomeAmount: {
		key: "realIncomeAmount",
		dataIndex: "realIncomeAmount",
		title: newFormat("funds.fund_audit.adjusted_revenue"),
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	incomeCheckRecord_lockStatus: {
		key: "lockStatus",
		dataIndex: "lockStatus",
		title: newFormat("funds.memberWithdrawalReview.approval_status"),
		align: "center",
		width: 120,
		render: (text: string, record: any) => (
			<span className={getAuditStatusClass(record)}>{getLabel(text, "auditStatus", false)}</span>
		)
	},
	incomeCheckRecord_lockTime: {
		key: "lockTime",
		dataIndex: "lockTime",
		title: newFormat("funds.fund_audit.lock_time"),
		align: "center",
		width: 120,
		render: (_text: any, record: any) => <p>{record.lockTime || "-"}</p>
	},
	incomeCheckRecord_auditName: {
		key: "auditName",
		dataIndex: "auditName",
		title: newFormat("funds.fund_audit.lock_account"),
		align: "center",
		width: 120,
		render: (_text: any, record: any) => <p>{record.auditName || "-"}</p>
	},
	incomeCheckRecord_proxyLevelName: {
		key: "proxyLevelName",
		dataIndex: "proxyLevelName",
		title: newFormat("common.profit_ratio"),
		align: "center",
		width: 120
	},
	incomeCheckRecord_proxyLevel: {
		key: "proxyLevel",
		dataIndex: "proxyLevel",
		title: newFormat("agent.agent_level"),
		align: "center",
		width: 120,
		render: renderNullableValue("proxyLevel")
	},
	incomeCheckRecord_parentProxy: {
		key: "parentProxyName",
		dataIndex: "parentProxyName",
		title: newFormat("report.parent_proxy"),
		align: "center",
		width: 120
	},
	incomeCheckRecord_applyTime: {
		key: "applyTime",
		dataIndex: "applyTime",
		title: newFormat("agent.apply_time"),
		align: "center",
		width: 120
	},
	AgentAccountInformation_userName: {
		key: "userName",
		dataIndex: "userName",
		title: newFormat("agent.agent_account"),
		align: "center",
		width: 120
	},
	AgentAccountInformation_proxyLevel: {
		key: "proxyLevel",
		dataIndex: "proxyLevel",
		title: newFormat("agent.agent_level"),
		align: "center",
		width: 120
	},
	AgentAccountInformation_parentProxyName: {
		key: "parentProxyName",
		dataIndex: "parentProxyName",
		title: newFormat("agent.direct_superior"),
		align: "center",
		width: 120
	},
	AgentAccountInformation_topProxyName: {
		key: "topProxyName",
		dataIndex: "topProxyName",
		title: newFormat("dict.proxy_level_list"),
		align: "center",
		width: 120
	},
	AgentAccountInformation_businessModel: {
		key: "businessModel",
		dataIndex: "businessModel",
		title: newFormat("label.member.business_model"),
		align: "center",
		width: 120,
		render: (_text: any) => <p>{mappingBusinessModel(_text, formatMessage) || "-"}</p>
	},
	AgentAccountInformation_paymentLockStatus: {
		key: "paymentLockStatus",
		dataIndex: "paymentLockStatus",
		title: newFormat("funds.proxy_member_funds_record.account_status"),
		align: "center",
		width: 120,
		render: (value: any, record: any) =>
			(() => {
				let context: string = ""
				let color = "success"
				if (record.paymentLockStatus) {
					context = newFormat("agent.withdraw_lock")
					color = "warning"
				} else if (record.loginLockStatus) {
					context = newFormat("common.login_lock_status")
					color = "error"
				} else if (record.loginLockStatus === 0 && record.paymentLockStatus === 0) {
					context = newFormat("common.account_status_normal")
					color = "success"
				}
				return (
					<span>
						<Tag color={color}>{context}</Tag>
					</span>
				)
			})()
	},
	AgentAccountInformation_createdAt: {
		key: "createdAt",
		dataIndex: "createdAt",
		title: newFormat("agent.register_time"),
		align: "center",
		width: 120
	},
	PeriodAgentIncomeStatistic_payoutStatus: {
		key: "payoutStatus",
		dataIndex: "payoutStatus",
		title: newFormat("funds.fund_audit.revenue_status"),
		align: "center",
		width: 120,
		render: (value: any, record: any) =>
			(() => {
				let context: string = ""
				let color = "success"
				if (record.payoutStatus === 6) {
					context = newFormat("dxn.card_ables_list.canceled")
					color = "warning"
				} else if (record.payoutStatus === 3) {
					context = newFormat("funds.fund_audit.issued")
					color = "success"
				} else if (record.payoutStatus === 1) {
					context = newFormat("funds.fund_audit.to_be_issued")
					color = "success"
				} else if (record.payoutStatus === 5) {
					context = newFormat("funds.fund_audit.no_income")
					color = "warning"
				} else if (record.payoutStatus === 0) {
					context = newFormat("funds.fund_audit.unsettlement")
					color = "warning"
				} else if (record.payoutStatus === 2) {
					context = newFormat("funds.fund_audit.waiting_for_collection")
					color = "warning"
				} else if (record.payoutStatus === 4) {
					context = newFormat("funds.fund_audit.timeout_and_no_collection")
					color = "warning"
				}
				return (
					<span>
						<Tag color={color}>{context}</Tag>
					</span>
				)
			})()
	},
	PeriodAgentIncomeStatistic_currentIncomeAmount: {
		key: "currentIncomeAmount",
		dataIndex: "currentIncomeAmount",
		title: newFormat("funds.fund_audit.revenue_status"),
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("sign", _text)
		}
	},
	PeriodAgentIncomeStatistic_adjustIncomeAmount: {
		key: "adjustIncomeAmount",
		dataIndex: "adjustIncomeAmount",
		title: newFormat("funds.fund_audit.revenue_adjustment"),
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("sign", _text)
		}
	},
	PeriodAgentIncomeStatistic_realIncomeAmount: {
		key: "realIncomeAmount",
		dataIndex: "realIncomeAmount",
		title: newFormat("funds.fund_audit.adjusted_earnings"),
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("sign", _text)
		}
	},
	PeriodAgentIncomeStatistic_audit1Desc: {
		key: "audit1Desc",
		dataIndex: "audit1Desc",
		title: newFormat("common.remarks"),
		align: "center",
		width: 120,
		render: (_text: any, record: any) => (
			<p>
				{record.audit1Desc || "-"} {record.audit2Desc || "-"}
			</p>
		)
	},

	RevenueDetailsColumn_payoutStatus: {
		key: "payoutStatus",
		dataIndex: "payoutStatus",
		title: newFormat("funds.fund_audit.project_item"),
		align: "center",
		width: 120,
		render: (_text: any) => <p>{newFormat("funds.fund_audit.texas_club")}</p>
	},
	RevenueDetailsColumn_clubAmount: {
		key: "clubAmount",
		dataIndex: "clubAmount",
		title: (
			<div>
				<p>
					<Tooltip title={newFormat("funds.fund_audit.service_fee_contribution")}>
						<div>{newFormat("common.service_charge")}</div>
					</Tooltip>
				</p>
			</div>
		),
		align: "center",
		width: 120,
		render: (_text: any) => {
			return <div onClick={() => {}}>{handleNumber("USDT", _text)}</div>
		}
	},
	RevenueDetailsColumn_rebateRate: {
		key: "rebateRate",
		dataIndex: "rebateRate",
		title: <div>{newFormat("funds.fund_audit.team_share_ratio")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => <span>{_text}%</span>
	},
	RevenueDetailsColumn_rebateAmount: {
		key: "rebateAmount",
		dataIndex: "rebateAmount",
		title: <div>{newFormat("funds.fund_audit.team_share_amount")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	RevenueDetailsColumn_underProxyAmount: {
		key: "underProxyAmount",
		dataIndex: "underProxyAmount",
		title: <div>{newFormat("funds.fund_audit.direct_agent_team_share_amount")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	RevenueDetailsColumn_memberRebateAmountByProxy: {
		key: "memberRebateAmountByProxy",
		dataIndex: "memberRebateAmountByProxy",
		title: <div>{newFormat("funds.fund_audit.member_agent_rebate")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	RevenueDetailsColumn_incomeAmount: {
		key: "incomeAmount",
		dataIndex: "incomeAmount",
		title: (
			<Tooltip title={newFormat("funds.fund_audit.the_actual_share_amount")}>
				<div>{newFormat("funds.fund_audit.actual_share_payable")}</div>
			</Tooltip>
		),
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},

	RevenueDetailsColumn1_payoutStatus: {
		key: "payoutStatus",
		dataIndex: "payoutStatus",
		title: newFormat("funds.fund_audit.project_item"),
		align: "center",
		width: 120,
		render: (_text: any) => <p>{newFormat("funds.fund_audit.texas_insurance")}</p>
	},
	RevenueDetailsColumn1_netAmount: {
		key: "netAmount",
		dataIndex: "netAmount",
		title: <div>{newFormat("funds.fund_audit.member_game_win_or_loss")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	RevenueDetailsColumn1_zhanchengRate: {
		key: "zhanchengRate",
		dataIndex: "zhanchengRate",
		title: <div>{newFormat("funds.fund_audit.team_share_ratio")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => <span>{_text}%</span>
	},
	RevenueDetailsColumn1_commissionNetAmount: {
		key: "commissionNetAmount",
		dataIndex: "commissionNetAmount",
		title: <div>{newFormat("funds.fund_audit.team_share_amount")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	RevenueDetailsColumn1_underProxyNetAmount: {
		key: "underProxyNetAmount",
		dataIndex: "underProxyNetAmount",
		title: <div>{newFormat("funds.fund_audit.direct_agent_team_share_amount")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	RevenueDetailsColumn1_incomeNetAmount: {
		key: "incomeNetAmount",
		dataIndex: "incomeNetAmount",
		title: (
			<div>
				<p>
					<Tooltip title={newFormat("funds.fund_audit.tooltip the_actual_share_amount1")}>
						<div>{newFormat("funds.fund_audit.actual_share_payable")}</div>
					</Tooltip>
				</p>
			</div>
		),
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},

	RevenueDetailsColumn2_payoutStatus: {
		key: "payoutStatus",
		dataIndex: "payoutStatus",
		title: newFormat("funds.fund_audit.project_item"),
		align: "center",
		width: 120,
		render: (_text: any) => <p>{newFormat("funds.fund_audit.texas_value_added_services")}</p>
	},
	RevenueDetailsColumn2_clubAmount: {
		key: "clubAmount",
		dataIndex: "clubAmount",
		title: <div>{newFormat("label.value_added_total_amount")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	RevenueDetailsColumn2_rebateRate: {
		key: "rebateRate",
		dataIndex: "rebateRate",
		title: <div>{newFormat("funds.fund_audit.team_share_ratio")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => <span>{_text}%</span>
	},
	RevenueDetailsColumn2_rebateAmount: {
		key: "rebateAmount",
		dataIndex: "rebateAmount",
		title: <div>{newFormat("funds.fund_audit.team_share_amount")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	RevenueDetailsColumn2_underProxyAmount: {
		key: "underProxyAmount",
		dataIndex: "underProxyAmount",
		title: <div>{newFormat("funds.fund_audit.direct_agent_team_share_amount")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	RevenueDetailsColumn2_incomeAmount: {
		key: "incomeAmount",
		dataIndex: "incomeAmount",
		title: (
			<div>
				<p>
					<Tooltip title={newFormat("funds.fund_audit.tooltip the_actual_share_amount1")}>
						<div>{newFormat("funds.fund_audit.actual_share_payable")}</div>
					</Tooltip>
				</p>
			</div>
		),
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},

	RevenueDetailsColumn3_venueName: {
		key: "venueName",
		dataIndex: "venueName",
		title: newFormat("funds.fund_audit.project_item"),
		align: "center",
		width: 120
	},
	RevenueDetailsColumn3_clubAmount: {
		key: "clubAmount",
		dataIndex: "clubAmount",
		title: <div>{newFormat("funds.fund_audit.members_valid_bets")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	RevenueDetailsColumn3_rebateRate: {
		key: "rebateRate",
		dataIndex: "rebateRate",
		title: <div>{newFormat("funds.fund_audit.subLabel")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => <span>{_text}%</span>
	},
	RevenueDetailsColumn3_rebateAmount: {
		key: "rebateAmount",
		dataIndex: "rebateAmount",
		title: <div>{newFormat("funds.fund_audit.team_rebate_amount")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	RevenueDetailsColumn3_underProxyAmount: {
		key: "underProxyAmount",
		dataIndex: "underProxyAmount",
		title: <div>{newFormat("funds.fund_audit.direct_agent_team_rebate_amount")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	RevenueDetailsColumn3_memberRebateAmountByProxy: {
		key: "memberRebateAmountByProxy",
		dataIndex: "memberRebateAmountByProxy",
		title: <div>{newFormat("funds.fund_audit.member_agent_rebate")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},
	RevenueDetailsColumn3_incomeAmount: {
		key: "incomeAmount",
		dataIndex: "incomeAmount",
		title: <div>{newFormat("funds.fund_audit.actual_rebate_amount_to_be_paid")}</div>,
		align: "center",
		width: 120,
		render: (_text: any) => {
			return handleNumber("USDT", _text)
		}
	},

	MemberAccountInformation_userName: {
		key: "userName",
		dataIndex: "userName",
		title: newFormat("funds.user_name"),
		align: "center",
		width: 120
	},
	MemberAccountInformation_parentProxyName: {
		key: "parentProxyName",
		dataIndex: "parentProxyName",
		title: newFormat("funds.fund_audit.belong_proxy"),
		align: "center",
		width: 120
	},
	MemberAccountInformation_merchantName: {
		key: "merchantName",
		dataIndex: "merchantName",
		title: newFormat("funds.member.merchantName"),
		align: "center",
		width: 120
	},
	MemberAccountInformation_paymentLockStatus: {
		key: "paymentLockStatus",
		dataIndex: "paymentLockStatus",
		title: newFormat("label.report.account_lock"),
		align: "center",
		width: 120,
		render: (_text: any) => <p>{newFormat("report.normal")}</p>
	},
	MemberAccountInformation_createdAt: {
		key: "createdAt",
		dataIndex: "createdAt",
		title: newFormat("common.register_time"),
		align: "center",
		width: 120,
		render: (_text: any) => <p>{newFormat("report.normal")}</p>
	},

	StatisticsOfRebates_memberName: {
		key: "memberName",
		dataIndex: "memberName",
		title: newFormat("funds.user_name"),
		align: "center",
		width: 120,
		render: (_text: any) => <p>{newFormat("funds.fund_audit.texas_club")}</p>
	},
	StatisticsOfRebates_payoutStatus: {
		key: "payoutStatus",
		dataIndex: "payoutStatus",
		title: newFormat("funds.bonusReviewRecord.table2.rebate_status"),
		align: "center",
		width: 120,
		render: (_text: any) => <p>{newFormat("funds.bonusReviewRecord.table2.rebate_status")}</p>
	},
	StatisticsOfRebates_personRebateAmount: {
		key: "personRebateAmount",
		dataIndex: "personRebateAmount",
		title: newFormat("funds.fund_audit.person_return_water"),
		align: "center",
		width: 120,
		render: (_text: any) => <p>{newFormat("funds.bonusReviewRecord.table2.rebate_status")}</p>
	},

	AgentRebateDetails_venueName: {
		key: "venueName",
		dataIndex: "venueName",
		title: newFormat("funds.user_name"),
		align: "center",
		width: 120,
		render: (_text: any) => <p>{newFormat("funds.fund_audit.texas_club")}</p>
	},
	AgentRebateDetails_rebateAmount: {
		key: "rebateAmount",
		dataIndex: "rebateAmount",
		title: newFormat("funds.bonusReviewRecord.personal_rebate"),
		align: "center",
		width: 120,
		render: (_text: any) => <p>{newFormat("funds.bonusReviewRecord.table2.rebate_status")}</p>
	},
	AgentRebateDetails_rebateRate: {
		key: "rebateRate",
		dataIndex: "rebateRate",
		title: newFormat("funds.bonusReviewRecord.table3.rebate_ratio"),
		align: "center",
		width: 120,
		render: (_text: any) => <p>{newFormat("funds.bonusReviewRecord.table2.rebate_status")}</p>
	},
	AgentRebateDetails_serviceAmountContribution: {
		key: "serviceAmountContribution",
		dataIndex: "serviceAmountContribution",
		title: newFormat("funds.bonusReviewRecord.table3.valid_bets"),
		align: "center",
		width: 120,
		render: (_text: any) => <p>{newFormat("funds.bonusReviewRecord.table2.rebate_status")}</p>
	}
})
